package cn.yunhe.model;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Component("Computer")
@Scope("prototype")
public class Computer {
    @Resource
    private MainFrame mainFrame;
    @Resource(name = "LenovoDisplay")
    private Display dispaly;

    public void showComputer(){
        System.out.println("台式机的配置如下：");
        mainFrame.
                showMainFrame();
        dispaly.showDisplay();
    }

    public Computer() {
    }

    public Computer(MainFrame mainFrame, Display dispaly) {
        this.mainFrame = mainFrame;
        this.dispaly = dispaly;
    }

    @PostConstruct
    public void postConstructTest(){
        System.out.println("构造函数实例化后被调用2Computer");
    }

    @PreDestroy
    public void preDestoryTest(){
        //@Scope("prototype")非单例模式下不起做用
        System.out.println("在销毁之前被调用2Computer");
    }

    public MainFrame getMainFrame() {
        return mainFrame;
    }

    public void setMainFrame(MainFrame mainFrame) {
        this.mainFrame = mainFrame;
    }



    public Display getDispaly() {
        return dispaly;
    }

    public void setDispaly(Display dispaly) {
        this.dispaly = dispaly;
    }
}
